package com.fengmi.controller;

import com.fengmi.cms.entity.Content;
import com.fengmi.goods.vo.GoodsCatVo;
import com.fengmi.goods.vo.HotGoodsVo;
import com.fengmi.service.ICacheService;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("cache")
public class CacheController {

    @Autowired
    private ICacheService cacheService;


    /**
     * 缓存内容
     * @param catId
     * @return
     */
    @RequestMapping("cms/findContentByCatId/{catId}")
    public List<Content> findContentByCatId(@PathVariable String catId){

        return  cacheService.cacheContent(catId);
    }

    /**
     * 缓存分类菜单
     * @return
     */
    @RequestMapping("cat")
    public List<GoodsCatVo> cat(){
        return  cacheService.cacheGoodsCat();
    }

    /**
     * 缓存热销商品topn
     * @return
     */
    @RequestMapping("hotGoods")
    public List<HotGoodsVo> hotGoods(){
        return  cacheService.cacheHotGoods();
    }

}
